package model

import (
	"gorm.io/gorm"
	"server/global"
)

// UserMoney 用户钱包
type UserMoney struct {
	UserID  int     `json:"user_id" gorm:"type:int;comment:'用户id'"`
	Balance float64 `json:"balance"`
	Status  string  `json:"status"`
}

func (UserMoney) TableName() string {
	return "user_money"
}

type UserMoneyModel struct {
	UserMoney
}

// Read 单条
func (a UserMoneyModel) Read(Userid int) (*gorm.DB, UserMoneyModel) {
	Db := global.GL_DB
	detail := UserMoneyModel{}
	Db.Model(&a).Where("id =?", Userid).First(&detail)
	Db.Model(&a).First(&detail)

	return Db, detail

}

// Update 编辑
func (a UserMoneyModel) Update() *gorm.DB {
	Db := global.GL_DB
	Db.Updates(&a)
	return Db

}
